// The module 'vscode' contains the VS Code extensibility API
// Import the module and reference it with the alias vscode in your code below
import * as vscode from 'vscode';

// This method is called when your extension is activated
// Your extension is activated the very first time the command is executed
export function activate(context: vscode.ExtensionContext) {

		// 注册转换成大写的命令
	const toUpperCommand = vscode.commands.registerCommand('codeConverter.toUpper', () => {
		const editor = vscode.window.activeTextEditor;
		if (editor) {
			const selection = editor.selection;
			const text = editor.document.getText(selection);
			editor.edit(editBuilder => {
				editBuilder.replace(selection, text.toUpperCase());
			});
		};
	});

	const toLowerCommand = vscode.commands.registerCommand('codeConverter.toLower', () => {
		const editor = vscode.window.activeTextEditor;
		if (editor) {
			const selection = editor.selection;
			const text = editor.document.getText(selection);
			editor.edit(editBuilder => {
				editBuilder.replace(selection, text.toLowerCase());
			});
		};
	});

	context.subscriptions.push(toUpperCommand, toLowerCommand);
}

// This method is called when your extension is deactivated
export function deactivate() {}
